namespace ParserGenerator.Languages.JSON
{
    public partial interface ISyntaxTreeNode : global::System.Collections.Generic.IReadOnlyList<global::ParserGenerator.Languages.JSON.ISyntaxTreeNode>
    {
        global::ParserGenerator.Input.SourceContext Context { get; set; }
    }

    [global::System.Serializable]
    public enum JsonValueCategory
    {
        Null,
        Boolean,
        Integer,
        Float,
        String,
        Array,
        Object,
    }

    [global::System.Serializable]
    public abstract partial class JsonValue : global::ParserGenerator.Languages.JSON.ISyntaxTreeNode
    {
        public global::ParserGenerator.Input.SourceContext Context { get; set; }
        public abstract global::ParserGenerator.Languages.JSON.JsonValueCategory Tag { get; }
        public bool IsNull => this is global::ParserGenerator.Languages.JSON.NullJsonValue;
        public bool IsBoolean => this is global::ParserGenerator.Languages.JSON.BooleanJsonValue;
        public bool IsInteger => this is global::ParserGenerator.Languages.JSON.IntegerJsonValue;
        public bool IsFloat => this is global::ParserGenerator.Languages.JSON.FloatJsonValue;
        public bool IsString => this is global::ParserGenerator.Languages.JSON.StringJsonValue;
        public bool IsArray => this is global::ParserGenerator.Languages.JSON.ArrayJsonValue;
        public bool IsObject => this is global::ParserGenerator.Languages.JSON.ObjectJsonValue;
        public global::ParserGenerator.Languages.JSON.NullJsonValue AsNull => (global::ParserGenerator.Languages.JSON.NullJsonValue)this;
        public global::ParserGenerator.Languages.JSON.BooleanJsonValue AsBoolean => (global::ParserGenerator.Languages.JSON.BooleanJsonValue)this;
        public global::ParserGenerator.Languages.JSON.IntegerJsonValue AsInteger => (global::ParserGenerator.Languages.JSON.IntegerJsonValue)this;
        public global::ParserGenerator.Languages.JSON.FloatJsonValue AsFloat => (global::ParserGenerator.Languages.JSON.FloatJsonValue)this;
        public global::ParserGenerator.Languages.JSON.StringJsonValue AsString => (global::ParserGenerator.Languages.JSON.StringJsonValue)this;
        public global::ParserGenerator.Languages.JSON.ArrayJsonValue AsArray => (global::ParserGenerator.Languages.JSON.ArrayJsonValue)this;
        public global::ParserGenerator.Languages.JSON.ObjectJsonValue AsObject => (global::ParserGenerator.Languages.JSON.ObjectJsonValue)this;

        int global::System.Collections.Generic.IReadOnlyCollection<global::ParserGenerator.Languages.JSON.ISyntaxTreeNode>.Count
        {
            get
            {
                throw new global::System.NotImplementedException();
            }
        }

        internal JsonValue(global::ParserGenerator.Input.SourceContext context = null)
        {
            Context = context;
        }

        public static global::ParserGenerator.Languages.JSON.JsonValue NewNull(global::ParserGenerator.Input.SourceContext context = null)
        {
            return new global::ParserGenerator.Languages.JSON.NullJsonValue(context);
        }

        public static global::ParserGenerator.Languages.JSON.JsonValue NewBoolean(bool value, global::ParserGenerator.Input.SourceContext context = null)
        {
            return new global::ParserGenerator.Languages.JSON.BooleanJsonValue(value, context);
        }

        public static global::ParserGenerator.Languages.JSON.JsonValue NewInteger(System.Numerics.BigInteger value, global::ParserGenerator.Input.SourceContext context = null)
        {
            if (value == null)
                throw new global::System.ArgumentNullException(nameof(value));
            return new global::ParserGenerator.Languages.JSON.IntegerJsonValue(value, context);
        }

        public static global::ParserGenerator.Languages.JSON.JsonValue NewFloat(double value, global::ParserGenerator.Input.SourceContext context = null)
        {
            return new global::ParserGenerator.Languages.JSON.FloatJsonValue(value, context);
        }

        public static global::ParserGenerator.Languages.JSON.JsonValue NewString(string value, global::ParserGenerator.Input.SourceContext context = null)
        {
            if (value == null)
                throw new global::System.ArgumentNullException(nameof(value));
            return new global::ParserGenerator.Languages.JSON.StringJsonValue(value, context);
        }

        public static global::ParserGenerator.Languages.JSON.JsonValue NewArray(global::ParserGenerator.Collections.Sequence<JsonValue> value, global::ParserGenerator.Input.SourceContext context = null)
        {
            if (value == null)
                throw new global::System.ArgumentNullException(nameof(value));
            return new global::ParserGenerator.Languages.JSON.ArrayJsonValue(value, context);
        }

        public static global::ParserGenerator.Languages.JSON.JsonValue NewObject(global::ParserGenerator.Collections.Sequence<global::System.Tuple<string, JsonValue>> value, global::ParserGenerator.Input.SourceContext context = null)
        {
            if (value == null)
                throw new global::System.ArgumentNullException(nameof(value));
            return new global::ParserGenerator.Languages.JSON.ObjectJsonValue(value, context);
        }

        global::ParserGenerator.Languages.JSON.ISyntaxTreeNode global::System.Collections.Generic.IReadOnlyList<global::ParserGenerator.Languages.JSON.ISyntaxTreeNode>.this[int i]
        {
            get
            {
                throw new global::System.NotImplementedException();
            }
        }

        global::System.Collections.Generic.IEnumerator<global::ParserGenerator.Languages.JSON.ISyntaxTreeNode> global::System.Collections.Generic.IEnumerable<global::ParserGenerator.Languages.JSON.ISyntaxTreeNode>.GetEnumerator()
        {
            throw new global::System.NotImplementedException();
        }

        global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() => ((global::ParserGenerator.Languages.JSON.ISyntaxTreeNode)this).GetEnumerator();
        public abstract void AcceptSyntaxTreeNodeWriter(global::ParserGenerator.Languages.JSON.ISyntaxTreeNodeWriter v, global::ParserGenerator.Output.IndentedWriter writer);
        public abstract void AcceptSyntaxTreeNodeWalker(global::ParserGenerator.Languages.JSON.SyntaxTreeNodeWalker v);

        public string ToString(global::ParserGenerator.Languages.JSON.ISyntaxTreeNodeWriter v)
        {
            if (v == null)
                throw new global::System.ArgumentNullException(nameof(v));
            using (var writer = new global::System.IO.StringWriter())
            {
                global::ParserGenerator.Output.IndentedWriter w = new global::ParserGenerator.Output.IndentedWriter(writer);
                v.WriteJsonValue(this, w);
                return writer.ToString().Trim();
            }
        }

        public sealed override string ToString()
        {
            return ToString(global::ParserGenerator.Languages.JSON.SyntaxTreeNodeWriter.Instance);
        }
    }

    [global::System.Serializable]
    public sealed partial class NullJsonValue : global::ParserGenerator.Languages.JSON.JsonValue, global::ParserGenerator.Languages.JSON.ISyntaxTreeNode
    {
        public sealed override global::ParserGenerator.Languages.JSON.JsonValueCategory Tag => global::ParserGenerator.Languages.JSON.JsonValueCategory.Null;
        int global::System.Collections.Generic.IReadOnlyCollection<global::ParserGenerator.Languages.JSON.ISyntaxTreeNode>.Count => 0;

        internal NullJsonValue(global::ParserGenerator.Input.SourceContext context = null)
            : base(context)
        {
        }

        public static global::ParserGenerator.Languages.JSON.NullJsonValue New(global::ParserGenerator.Input.SourceContext context = null)
        {
            return new global::ParserGenerator.Languages.JSON.NullJsonValue(context);
        }

        public global::ParserGenerator.Languages.JSON.NullJsonValue Copy()
        {
            return new global::ParserGenerator.Languages.JSON.NullJsonValue(Context);
        }

        public global::ParserGenerator.Languages.JSON.NullJsonValue WithContext(global::ParserGenerator.Input.SourceContext context)
        {
            return new global::ParserGenerator.Languages.JSON.NullJsonValue(context);
        }

        global::ParserGenerator.Languages.JSON.ISyntaxTreeNode global::System.Collections.Generic.IReadOnlyList<global::ParserGenerator.Languages.JSON.ISyntaxTreeNode>.this[int i]
        {
            get
            {
                switch (i)
                {
                    default:
                        {
                            if (i < 0)
                                throw new global::System.ArgumentOutOfRangeException(nameof(i), string.Format(global::ParserGenerator.SR.ArgumentMustBeNonNegative, nameof(i)));
                            throw new global::System.ArgumentOutOfRangeException(nameof(i));
                        }
                }
            }
        }

        global::System.Collections.Generic.IEnumerator<global::ParserGenerator.Languages.JSON.ISyntaxTreeNode> global::System.Collections.Generic.IEnumerable<global::ParserGenerator.Languages.JSON.ISyntaxTreeNode>.GetEnumerator()
        {
            yield break;
        }

        public sealed override void AcceptSyntaxTreeNodeWriter(global::ParserGenerator.Languages.JSON.ISyntaxTreeNodeWriter v, global::ParserGenerator.Output.IndentedWriter writer)
        {
            if (v == null)
                throw new global::System.ArgumentNullException(nameof(v));
            if (writer == null)
                throw new global::System.ArgumentNullException(nameof(writer));
            v.WriteNullJsonValue(this, writer);
        }

        public sealed override void AcceptSyntaxTreeNodeWalker(global::ParserGenerator.Languages.JSON.SyntaxTreeNodeWalker v)
        {
            if (v == null)
                throw new global::System.ArgumentNullException(nameof(v));
            v.WalkNullJsonValue(this);
        }
    }

    [global::System.Serializable]
    public sealed partial class BooleanJsonValue : global::ParserGenerator.Languages.JSON.JsonValue, global::ParserGenerator.Languages.JSON.ISyntaxTreeNode
    {
        public bool Value { get; }
        public sealed override global::ParserGenerator.Languages.JSON.JsonValueCategory Tag => global::ParserGenerator.Languages.JSON.JsonValueCategory.Boolean;
        int global::System.Collections.Generic.IReadOnlyCollection<global::ParserGenerator.Languages.JSON.ISyntaxTreeNode>.Count => 0;

        internal BooleanJsonValue(bool value, global::ParserGenerator.Input.SourceContext context = null)
            : base(context)
        {
            Value = value;
        }

        public static global::ParserGenerator.Languages.JSON.BooleanJsonValue New(bool value, global::ParserGenerator.Input.SourceContext context = null)
        {
            return new global::ParserGenerator.Languages.JSON.BooleanJsonValue(value, context);
        }

        public global::ParserGenerator.Languages.JSON.BooleanJsonValue Copy()
        {
            return new global::ParserGenerator.Languages.JSON.BooleanJsonValue(Value, Context);
        }

        public global::ParserGenerator.Languages.JSON.BooleanJsonValue WithValue(bool value)
        {
            return new global::ParserGenerator.Languages.JSON.BooleanJsonValue(value, Context);
        }

        public global::ParserGenerator.Languages.JSON.BooleanJsonValue WithContext(global::ParserGenerator.Input.SourceContext context)
        {
            return new global::ParserGenerator.Languages.JSON.BooleanJsonValue(Value, context);
        }

        global::ParserGenerator.Languages.JSON.ISyntaxTreeNode global::System.Collections.Generic.IReadOnlyList<global::ParserGenerator.Languages.JSON.ISyntaxTreeNode>.this[int i]
        {
            get
            {
                switch (i)
                {
                    default:
                        {
                            if (i < 0)
                                throw new global::System.ArgumentOutOfRangeException(nameof(i), string.Format(global::ParserGenerator.SR.ArgumentMustBeNonNegative, nameof(i)));
                            throw new global::System.ArgumentOutOfRangeException(nameof(i));
                        }
                }
            }
        }

        global::System.Collections.Generic.IEnumerator<global::ParserGenerator.Languages.JSON.ISyntaxTreeNode> global::System.Collections.Generic.IEnumerable<global::ParserGenerator.Languages.JSON.ISyntaxTreeNode>.GetEnumerator()
        {
            yield break;
        }

        public sealed override void AcceptSyntaxTreeNodeWriter(global::ParserGenerator.Languages.JSON.ISyntaxTreeNodeWriter v, global::ParserGenerator.Output.IndentedWriter writer)
        {
            if (v == null)
                throw new global::System.ArgumentNullException(nameof(v));
            if (writer == null)
                throw new global::System.ArgumentNullException(nameof(writer));
            v.WriteBooleanJsonValue(this, writer);
        }

        public sealed override void AcceptSyntaxTreeNodeWalker(global::ParserGenerator.Languages.JSON.SyntaxTreeNodeWalker v)
        {
            if (v == null)
                throw new global::System.ArgumentNullException(nameof(v));
            v.WalkBooleanJsonValue(this);
        }
    }

    [global::System.Serializable]
    public sealed partial class IntegerJsonValue : global::ParserGenerator.Languages.JSON.JsonValue, global::ParserGenerator.Languages.JSON.ISyntaxTreeNode
    {
        public System.Numerics.BigInteger Value { get; }
        public sealed override global::ParserGenerator.Languages.JSON.JsonValueCategory Tag => global::ParserGenerator.Languages.JSON.JsonValueCategory.Integer;
        int global::System.Collections.Generic.IReadOnlyCollection<global::ParserGenerator.Languages.JSON.ISyntaxTreeNode>.Count => 0;

        internal IntegerJsonValue(System.Numerics.BigInteger value, global::ParserGenerator.Input.SourceContext context = null)
            : base(context)
        {
            if (value == null)
                throw new global::System.ArgumentNullException(nameof(value));
            Value = value;
        }

        public static global::ParserGenerator.Languages.JSON.IntegerJsonValue New(System.Numerics.BigInteger value, global::ParserGenerator.Input.SourceContext context = null)
        {
            if (value == null)
                throw new global::System.ArgumentNullException(nameof(value));
            return new global::ParserGenerator.Languages.JSON.IntegerJsonValue(value, context);
        }

        public global::ParserGenerator.Languages.JSON.IntegerJsonValue Copy()
        {
            return new global::ParserGenerator.Languages.JSON.IntegerJsonValue(Value, Context);
        }

        public global::ParserGenerator.Languages.JSON.IntegerJsonValue WithValue(System.Numerics.BigInteger value)
        {
            if (value == null)
                throw new global::System.ArgumentNullException(nameof(value));
            return new global::ParserGenerator.Languages.JSON.IntegerJsonValue(value, Context);
        }

        public global::ParserGenerator.Languages.JSON.IntegerJsonValue WithContext(global::ParserGenerator.Input.SourceContext context)
        {
            return new global::ParserGenerator.Languages.JSON.IntegerJsonValue(Value, context);
        }

        global::ParserGenerator.Languages.JSON.ISyntaxTreeNode global::System.Collections.Generic.IReadOnlyList<global::ParserGenerator.Languages.JSON.ISyntaxTreeNode>.this[int i]
        {
            get
            {
                switch (i)
                {
                    default:
                        {
                            if (i < 0)
                                throw new global::System.ArgumentOutOfRangeException(nameof(i), string.Format(global::ParserGenerator.SR.ArgumentMustBeNonNegative, nameof(i)));
                            throw new global::System.ArgumentOutOfRangeException(nameof(i));
                        }
                }
            }
        }

        global::System.Collections.Generic.IEnumerator<global::ParserGenerator.Languages.JSON.ISyntaxTreeNode> global::System.Collections.Generic.IEnumerable<global::ParserGenerator.Languages.JSON.ISyntaxTreeNode>.GetEnumerator()
        {
            yield break;
        }

        public sealed override void AcceptSyntaxTreeNodeWriter(global::ParserGenerator.Languages.JSON.ISyntaxTreeNodeWriter v, global::ParserGenerator.Output.IndentedWriter writer)
        {
            if (v == null)
                throw new global::System.ArgumentNullException(nameof(v));
            if (writer == null)
                throw new global::System.ArgumentNullException(nameof(writer));
            v.WriteIntegerJsonValue(this, writer);
        }

        public sealed override void AcceptSyntaxTreeNodeWalker(global::ParserGenerator.Languages.JSON.SyntaxTreeNodeWalker v)
        {
            if (v == null)
                throw new global::System.ArgumentNullException(nameof(v));
            v.WalkIntegerJsonValue(this);
        }
    }

    [global::System.Serializable]
    public sealed partial class FloatJsonValue : global::ParserGenerator.Languages.JSON.JsonValue, global::ParserGenerator.Languages.JSON.ISyntaxTreeNode
    {
        public double Value { get; }
        public sealed override global::ParserGenerator.Languages.JSON.JsonValueCategory Tag => global::ParserGenerator.Languages.JSON.JsonValueCategory.Float;
        int global::System.Collections.Generic.IReadOnlyCollection<global::ParserGenerator.Languages.JSON.ISyntaxTreeNode>.Count => 0;

        internal FloatJsonValue(double value, global::ParserGenerator.Input.SourceContext context = null)
            : base(context)
        {
            Value = value;
        }

        public static global::ParserGenerator.Languages.JSON.FloatJsonValue New(double value, global::ParserGenerator.Input.SourceContext context = null)
        {
            return new global::ParserGenerator.Languages.JSON.FloatJsonValue(value, context);
        }

        public global::ParserGenerator.Languages.JSON.FloatJsonValue Copy()
        {
            return new global::ParserGenerator.Languages.JSON.FloatJsonValue(Value, Context);
        }

        public global::ParserGenerator.Languages.JSON.FloatJsonValue WithValue(double value)
        {
            return new global::ParserGenerator.Languages.JSON.FloatJsonValue(value, Context);
        }

        public global::ParserGenerator.Languages.JSON.FloatJsonValue WithContext(global::ParserGenerator.Input.SourceContext context)
        {
            return new global::ParserGenerator.Languages.JSON.FloatJsonValue(Value, context);
        }

        global::ParserGenerator.Languages.JSON.ISyntaxTreeNode global::System.Collections.Generic.IReadOnlyList<global::ParserGenerator.Languages.JSON.ISyntaxTreeNode>.this[int i]
        {
            get
            {
                switch (i)
                {
                    default:
                        {
                            if (i < 0)
                                throw new global::System.ArgumentOutOfRangeException(nameof(i), string.Format(global::ParserGenerator.SR.ArgumentMustBeNonNegative, nameof(i)));
                            throw new global::System.ArgumentOutOfRangeException(nameof(i));
                        }
                }
            }
        }

        global::System.Collections.Generic.IEnumerator<global::ParserGenerator.Languages.JSON.ISyntaxTreeNode> global::System.Collections.Generic.IEnumerable<global::ParserGenerator.Languages.JSON.ISyntaxTreeNode>.GetEnumerator()
        {
            yield break;
        }

        public sealed override void AcceptSyntaxTreeNodeWriter(global::ParserGenerator.Languages.JSON.ISyntaxTreeNodeWriter v, global::ParserGenerator.Output.IndentedWriter writer)
        {
            if (v == null)
                throw new global::System.ArgumentNullException(nameof(v));
            if (writer == null)
                throw new global::System.ArgumentNullException(nameof(writer));
            v.WriteFloatJsonValue(this, writer);
        }

        public sealed override void AcceptSyntaxTreeNodeWalker(global::ParserGenerator.Languages.JSON.SyntaxTreeNodeWalker v)
        {
            if (v == null)
                throw new global::System.ArgumentNullException(nameof(v));
            v.WalkFloatJsonValue(this);
        }
    }

    [global::System.Serializable]
    public sealed partial class StringJsonValue : global::ParserGenerator.Languages.JSON.JsonValue, global::ParserGenerator.Languages.JSON.ISyntaxTreeNode
    {
        public string Value { get; }
        public sealed override global::ParserGenerator.Languages.JSON.JsonValueCategory Tag => global::ParserGenerator.Languages.JSON.JsonValueCategory.String;
        int global::System.Collections.Generic.IReadOnlyCollection<global::ParserGenerator.Languages.JSON.ISyntaxTreeNode>.Count => 0;

        internal StringJsonValue(string value, global::ParserGenerator.Input.SourceContext context = null)
            : base(context)
        {
            if (value == null)
                throw new global::System.ArgumentNullException(nameof(value));
            Value = value;
        }

        public static global::ParserGenerator.Languages.JSON.StringJsonValue New(string value, global::ParserGenerator.Input.SourceContext context = null)
        {
            if (value == null)
                throw new global::System.ArgumentNullException(nameof(value));
            return new global::ParserGenerator.Languages.JSON.StringJsonValue(value, context);
        }

        public global::ParserGenerator.Languages.JSON.StringJsonValue Copy()
        {
            return new global::ParserGenerator.Languages.JSON.StringJsonValue(Value, Context);
        }

        public global::ParserGenerator.Languages.JSON.StringJsonValue WithValue(string value)
        {
            if (value == null)
                throw new global::System.ArgumentNullException(nameof(value));
            return new global::ParserGenerator.Languages.JSON.StringJsonValue(value, Context);
        }

        public global::ParserGenerator.Languages.JSON.StringJsonValue WithContext(global::ParserGenerator.Input.SourceContext context)
        {
            return new global::ParserGenerator.Languages.JSON.StringJsonValue(Value, context);
        }

        global::ParserGenerator.Languages.JSON.ISyntaxTreeNode global::System.Collections.Generic.IReadOnlyList<global::ParserGenerator.Languages.JSON.ISyntaxTreeNode>.this[int i]
        {
            get
            {
                switch (i)
                {
                    default:
                        {
                            if (i < 0)
                                throw new global::System.ArgumentOutOfRangeException(nameof(i), string.Format(global::ParserGenerator.SR.ArgumentMustBeNonNegative, nameof(i)));
                            throw new global::System.ArgumentOutOfRangeException(nameof(i));
                        }
                }
            }
        }

        global::System.Collections.Generic.IEnumerator<global::ParserGenerator.Languages.JSON.ISyntaxTreeNode> global::System.Collections.Generic.IEnumerable<global::ParserGenerator.Languages.JSON.ISyntaxTreeNode>.GetEnumerator()
        {
            yield break;
        }

        public sealed override void AcceptSyntaxTreeNodeWriter(global::ParserGenerator.Languages.JSON.ISyntaxTreeNodeWriter v, global::ParserGenerator.Output.IndentedWriter writer)
        {
            if (v == null)
                throw new global::System.ArgumentNullException(nameof(v));
            if (writer == null)
                throw new global::System.ArgumentNullException(nameof(writer));
            v.WriteStringJsonValue(this, writer);
        }

        public sealed override void AcceptSyntaxTreeNodeWalker(global::ParserGenerator.Languages.JSON.SyntaxTreeNodeWalker v)
        {
            if (v == null)
                throw new global::System.ArgumentNullException(nameof(v));
            v.WalkStringJsonValue(this);
        }
    }

    [global::System.Serializable]
    public sealed partial class ArrayJsonValue : global::ParserGenerator.Languages.JSON.JsonValue, global::ParserGenerator.Languages.JSON.ISyntaxTreeNode
    {
        public global::ParserGenerator.Collections.Sequence<JsonValue> Value { get; }
        public sealed override global::ParserGenerator.Languages.JSON.JsonValueCategory Tag => global::ParserGenerator.Languages.JSON.JsonValueCategory.Array;
        int global::System.Collections.Generic.IReadOnlyCollection<global::ParserGenerator.Languages.JSON.ISyntaxTreeNode>.Count => Value.Count;

        internal ArrayJsonValue(global::ParserGenerator.Collections.Sequence<JsonValue> value, global::ParserGenerator.Input.SourceContext context = null)
            : base(context)
        {
            if (value == null)
                throw new global::System.ArgumentNullException(nameof(value));
            Value = value;
        }

        public static global::ParserGenerator.Languages.JSON.ArrayJsonValue New(global::ParserGenerator.Collections.Sequence<JsonValue> value, global::ParserGenerator.Input.SourceContext context = null)
        {
            if (value == null)
                throw new global::System.ArgumentNullException(nameof(value));
            return new global::ParserGenerator.Languages.JSON.ArrayJsonValue(value, context);
        }

        public global::ParserGenerator.Languages.JSON.ArrayJsonValue Copy()
        {
            return new global::ParserGenerator.Languages.JSON.ArrayJsonValue(Value, Context);
        }

        public global::ParserGenerator.Languages.JSON.ArrayJsonValue WithValue(global::ParserGenerator.Collections.Sequence<JsonValue> value)
        {
            if (value == null)
                throw new global::System.ArgumentNullException(nameof(value));
            return new global::ParserGenerator.Languages.JSON.ArrayJsonValue(value, Context);
        }

        public global::ParserGenerator.Languages.JSON.ArrayJsonValue WithContext(global::ParserGenerator.Input.SourceContext context)
        {
            return new global::ParserGenerator.Languages.JSON.ArrayJsonValue(Value, context);
        }

        global::ParserGenerator.Languages.JSON.ISyntaxTreeNode global::System.Collections.Generic.IReadOnlyList<global::ParserGenerator.Languages.JSON.ISyntaxTreeNode>.this[int i]
        {
            get
            {
                if (i < 0)
                    throw new global::System.ArgumentOutOfRangeException(nameof(i), string.Format(global::ParserGenerator.SR.ArgumentMustBeNonNegative, nameof(i)));
                int count = 0;
                if (count <= i && i < count + Value.Count)
                    return Value[i - count];
                count += Value.Count;
                throw new global::System.ArgumentOutOfRangeException(nameof(i));
            }
        }

        global::System.Collections.Generic.IEnumerator<global::ParserGenerator.Languages.JSON.ISyntaxTreeNode> global::System.Collections.Generic.IEnumerable<global::ParserGenerator.Languages.JSON.ISyntaxTreeNode>.GetEnumerator()
        {
            return Value.GetEnumerator();
        }

        public sealed override void AcceptSyntaxTreeNodeWriter(global::ParserGenerator.Languages.JSON.ISyntaxTreeNodeWriter v, global::ParserGenerator.Output.IndentedWriter writer)
        {
            if (v == null)
                throw new global::System.ArgumentNullException(nameof(v));
            if (writer == null)
                throw new global::System.ArgumentNullException(nameof(writer));
            v.WriteArrayJsonValue(this, writer);
        }

        public sealed override void AcceptSyntaxTreeNodeWalker(global::ParserGenerator.Languages.JSON.SyntaxTreeNodeWalker v)
        {
            if (v == null)
                throw new global::System.ArgumentNullException(nameof(v));
            v.WalkArrayJsonValue(this);
        }
    }

    [global::System.Serializable]
    public sealed partial class ObjectJsonValue : global::ParserGenerator.Languages.JSON.JsonValue, global::ParserGenerator.Languages.JSON.ISyntaxTreeNode
    {
        public global::ParserGenerator.Collections.Sequence<global::System.Tuple<string, JsonValue>> Value { get; }
        public sealed override global::ParserGenerator.Languages.JSON.JsonValueCategory Tag => global::ParserGenerator.Languages.JSON.JsonValueCategory.Object;
        int global::System.Collections.Generic.IReadOnlyCollection<global::ParserGenerator.Languages.JSON.ISyntaxTreeNode>.Count => 0;

        internal ObjectJsonValue(global::ParserGenerator.Collections.Sequence<global::System.Tuple<string, JsonValue>> value, global::ParserGenerator.Input.SourceContext context = null)
            : base(context)
        {
            if (value == null)
                throw new global::System.ArgumentNullException(nameof(value));
            Value = value;
        }

        public static global::ParserGenerator.Languages.JSON.ObjectJsonValue New(global::ParserGenerator.Collections.Sequence<global::System.Tuple<string, JsonValue>> value, global::ParserGenerator.Input.SourceContext context = null)
        {
            if (value == null)
                throw new global::System.ArgumentNullException(nameof(value));
            return new global::ParserGenerator.Languages.JSON.ObjectJsonValue(value, context);
        }

        public global::ParserGenerator.Languages.JSON.ObjectJsonValue Copy()
        {
            return new global::ParserGenerator.Languages.JSON.ObjectJsonValue(Value, Context);
        }

        public global::ParserGenerator.Languages.JSON.ObjectJsonValue WithValue(global::ParserGenerator.Collections.Sequence<global::System.Tuple<string, JsonValue>> value)
        {
            if (value == null)
                throw new global::System.ArgumentNullException(nameof(value));
            return new global::ParserGenerator.Languages.JSON.ObjectJsonValue(value, Context);
        }

        public global::ParserGenerator.Languages.JSON.ObjectJsonValue WithContext(global::ParserGenerator.Input.SourceContext context)
        {
            return new global::ParserGenerator.Languages.JSON.ObjectJsonValue(Value, context);
        }

        global::ParserGenerator.Languages.JSON.ISyntaxTreeNode global::System.Collections.Generic.IReadOnlyList<global::ParserGenerator.Languages.JSON.ISyntaxTreeNode>.this[int i]
        {
            get
            {
                switch (i)
                {
                    default:
                        {
                            if (i < 0)
                                throw new global::System.ArgumentOutOfRangeException(nameof(i), string.Format(global::ParserGenerator.SR.ArgumentMustBeNonNegative, nameof(i)));
                            throw new global::System.ArgumentOutOfRangeException(nameof(i));
                        }
                }
            }
        }

        global::System.Collections.Generic.IEnumerator<global::ParserGenerator.Languages.JSON.ISyntaxTreeNode> global::System.Collections.Generic.IEnumerable<global::ParserGenerator.Languages.JSON.ISyntaxTreeNode>.GetEnumerator()
        {
            yield break;
        }

        public sealed override void AcceptSyntaxTreeNodeWriter(global::ParserGenerator.Languages.JSON.ISyntaxTreeNodeWriter v, global::ParserGenerator.Output.IndentedWriter writer)
        {
            if (v == null)
                throw new global::System.ArgumentNullException(nameof(v));
            if (writer == null)
                throw new global::System.ArgumentNullException(nameof(writer));
            v.WriteObjectJsonValue(this, writer);
        }

        public sealed override void AcceptSyntaxTreeNodeWalker(global::ParserGenerator.Languages.JSON.SyntaxTreeNodeWalker v)
        {
            if (v == null)
                throw new global::System.ArgumentNullException(nameof(v));
            v.WalkObjectJsonValue(this);
        }
    }

    public partial interface ISyntaxTreeNodeWriter
    {
        void WriteJsonValue(global::ParserGenerator.Languages.JSON.JsonValue n, global::ParserGenerator.Output.IndentedWriter writer);
        void WriteNullJsonValue(global::ParserGenerator.Languages.JSON.NullJsonValue n, global::ParserGenerator.Output.IndentedWriter writer);
        void WriteBooleanJsonValue(global::ParserGenerator.Languages.JSON.BooleanJsonValue n, global::ParserGenerator.Output.IndentedWriter writer);
        void WriteIntegerJsonValue(global::ParserGenerator.Languages.JSON.IntegerJsonValue n, global::ParserGenerator.Output.IndentedWriter writer);
        void WriteFloatJsonValue(global::ParserGenerator.Languages.JSON.FloatJsonValue n, global::ParserGenerator.Output.IndentedWriter writer);
        void WriteStringJsonValue(global::ParserGenerator.Languages.JSON.StringJsonValue n, global::ParserGenerator.Output.IndentedWriter writer);
        void WriteArrayJsonValue(global::ParserGenerator.Languages.JSON.ArrayJsonValue n, global::ParserGenerator.Output.IndentedWriter writer);
        void WriteObjectJsonValue(global::ParserGenerator.Languages.JSON.ObjectJsonValue n, global::ParserGenerator.Output.IndentedWriter writer);
    }

    [global::System.Serializable]
    public partial class SyntaxTreeNodeWriter : global::ParserGenerator.Languages.JSON.ISyntaxTreeNodeWriter
    {
        public static global::ParserGenerator.Languages.JSON.SyntaxTreeNodeWriter Instance { get; } = new global::ParserGenerator.Languages.JSON.SyntaxTreeNodeWriter();

        public virtual void WriteJsonValue(global::ParserGenerator.Languages.JSON.JsonValue n, global::ParserGenerator.Output.IndentedWriter writer)
        {
            if (n == null)
                throw new global::System.ArgumentNullException(nameof(n));
            if (writer == null)
                throw new global::System.ArgumentNullException(nameof(writer));
            n.AcceptSyntaxTreeNodeWriter(this, writer);
        }
    }

    [global::System.Serializable]
    public partial class SyntaxTreeNodeWalker
    {
        public virtual void WalkJsonValue(global::ParserGenerator.Languages.JSON.JsonValue n)
        {
            if (n == null)
                throw new global::System.ArgumentNullException(nameof(n));
            n.AcceptSyntaxTreeNodeWalker(this);
        }

        public virtual void EnterNullJsonValue(global::ParserGenerator.Languages.JSON.NullJsonValue n)
        {
            if (n == null)
                throw new global::System.ArgumentNullException(nameof(n));
        }

        public virtual void LeaveNullJsonValue(global::ParserGenerator.Languages.JSON.NullJsonValue n)
        {
            if (n == null)
                throw new global::System.ArgumentNullException(nameof(n));
        }

        public virtual void WalkNullJsonValue(global::ParserGenerator.Languages.JSON.NullJsonValue n)
        {
            if (n == null)
                throw new global::System.ArgumentNullException(nameof(n));
            EnterNullJsonValue(n);
            LeaveNullJsonValue(n);
        }

        public virtual void EnterBooleanJsonValue(global::ParserGenerator.Languages.JSON.BooleanJsonValue n)
        {
            if (n == null)
                throw new global::System.ArgumentNullException(nameof(n));
        }

        public virtual void LeaveBooleanJsonValue(global::ParserGenerator.Languages.JSON.BooleanJsonValue n)
        {
            if (n == null)
                throw new global::System.ArgumentNullException(nameof(n));
        }

        public virtual void WalkBooleanJsonValue(global::ParserGenerator.Languages.JSON.BooleanJsonValue n)
        {
            if (n == null)
                throw new global::System.ArgumentNullException(nameof(n));
            EnterBooleanJsonValue(n);
            LeaveBooleanJsonValue(n);
        }

        public virtual void EnterIntegerJsonValue(global::ParserGenerator.Languages.JSON.IntegerJsonValue n)
        {
            if (n == null)
                throw new global::System.ArgumentNullException(nameof(n));
        }

        public virtual void LeaveIntegerJsonValue(global::ParserGenerator.Languages.JSON.IntegerJsonValue n)
        {
            if (n == null)
                throw new global::System.ArgumentNullException(nameof(n));
        }

        public virtual void WalkIntegerJsonValue(global::ParserGenerator.Languages.JSON.IntegerJsonValue n)
        {
            if (n == null)
                throw new global::System.ArgumentNullException(nameof(n));
            EnterIntegerJsonValue(n);
            LeaveIntegerJsonValue(n);
        }

        public virtual void EnterFloatJsonValue(global::ParserGenerator.Languages.JSON.FloatJsonValue n)
        {
            if (n == null)
                throw new global::System.ArgumentNullException(nameof(n));
        }

        public virtual void LeaveFloatJsonValue(global::ParserGenerator.Languages.JSON.FloatJsonValue n)
        {
            if (n == null)
                throw new global::System.ArgumentNullException(nameof(n));
        }

        public virtual void WalkFloatJsonValue(global::ParserGenerator.Languages.JSON.FloatJsonValue n)
        {
            if (n == null)
                throw new global::System.ArgumentNullException(nameof(n));
            EnterFloatJsonValue(n);
            LeaveFloatJsonValue(n);
        }

        public virtual void EnterStringJsonValue(global::ParserGenerator.Languages.JSON.StringJsonValue n)
        {
            if (n == null)
                throw new global::System.ArgumentNullException(nameof(n));
        }

        public virtual void LeaveStringJsonValue(global::ParserGenerator.Languages.JSON.StringJsonValue n)
        {
            if (n == null)
                throw new global::System.ArgumentNullException(nameof(n));
        }

        public virtual void WalkStringJsonValue(global::ParserGenerator.Languages.JSON.StringJsonValue n)
        {
            if (n == null)
                throw new global::System.ArgumentNullException(nameof(n));
            EnterStringJsonValue(n);
            LeaveStringJsonValue(n);
        }

        public virtual void EnterArrayJsonValue(global::ParserGenerator.Languages.JSON.ArrayJsonValue n)
        {
            if (n == null)
                throw new global::System.ArgumentNullException(nameof(n));
        }

        public virtual void LeaveArrayJsonValue(global::ParserGenerator.Languages.JSON.ArrayJsonValue n)
        {
            if (n == null)
                throw new global::System.ArgumentNullException(nameof(n));
        }

        public virtual void WalkArrayJsonValue(global::ParserGenerator.Languages.JSON.ArrayJsonValue n)
        {
            if (n == null)
                throw new global::System.ArgumentNullException(nameof(n));
            EnterArrayJsonValue(n);
            foreach (var child in n.Value)
                WalkJsonValue(child);
            LeaveArrayJsonValue(n);
        }

        public virtual void EnterObjectJsonValue(global::ParserGenerator.Languages.JSON.ObjectJsonValue n)
        {
            if (n == null)
                throw new global::System.ArgumentNullException(nameof(n));
        }

        public virtual void LeaveObjectJsonValue(global::ParserGenerator.Languages.JSON.ObjectJsonValue n)
        {
            if (n == null)
                throw new global::System.ArgumentNullException(nameof(n));
        }

        public virtual void WalkObjectJsonValue(global::ParserGenerator.Languages.JSON.ObjectJsonValue n)
        {
            if (n == null)
                throw new global::System.ArgumentNullException(nameof(n));
            EnterObjectJsonValue(n);
            LeaveObjectJsonValue(n);
        }
    }
}

namespace ParserGenerator.Languages.JSON
{
    using ParserGenerator.Collections;

    [global::System.Serializable]
    public sealed partial class JSONParser
    {
        private int _currentStart;
        private readonly global::System.Collections.Generic.Stack<int> _savedStarts = new global::System.Collections.Generic.Stack<int>();
        private global::ParserGenerator.Input.SourceContext _nodeContext;
        private readonly global::System.Collections.Generic.List<int> _states = new global::System.Collections.Generic.List<int>();
        private readonly global::System.Collections.Generic.List<string> _symbols = new global::System.Collections.Generic.List<string>();
        private readonly global::System.Collections.Generic.List<object> _values = new global::System.Collections.Generic.List<object>();
        private readonly global::System.Collections.Generic.List<global::ParserGenerator.Input.SourceContext> _contexts = new global::System.Collections.Generic.List<global::ParserGenerator.Input.SourceContext>();

        public global::ParserGenerator.Input.SourceReader Reader { get; private set; }
        public global::ParserGenerator.Input.SourceLocation TokenBegin { get; private set; }
        public global::ParserGenerator.Input.SourceLocation TokenEnd { get; private set; }
        public global::ParserGenerator.Input.SourceContext TokenContext { get; private set; }
        public object TokenValue { get; private set; }
        public int Level { get; private set; }

        public const int NoneTokenTag = 0;
        public const int IntegerLiteralTokenTag = 1;
        public const int FloatLiteralTokenTag = 2;
        public const int StringLiteralTokenTag = 3;

        public JSONParser()
            : this(global::ParserGenerator.Input.SourceReader.FromConsole())
        {
        }

        public JSONParser(global::ParserGenerator.Input.SourceReader reader)
        {
            if (reader == null)
                throw new global::System.ArgumentNullException(nameof(reader));
            Reader = reader;
            TokenBegin = TokenEnd = Reader.Location;
        }

        private void PushStart(int start)
        {
            _savedStarts.Push(_currentStart);
            _currentStart = start;
        }

        private void GotoStart(int start)
        {
            _currentStart = start;
        }

        private void PopStart()
        {
            _currentStart = _savedStarts.Pop();
        }

        public global::ParserGenerator.Exceptions.SyntaxErrorException SyntaxError(string message, global::ParserGenerator.Input.SourceLocation location)
        {
            if (message == null)
                throw new global::System.ArgumentNullException(nameof(message));
            global::ParserGenerator.Exceptions.SyntaxErrorException e = new global::ParserGenerator.Exceptions.SyntaxErrorException(message);
            e.AddLocation(location);
            return e;
        }

        public global::ParserGenerator.Exceptions.SyntaxErrorException SyntaxError(string message, global::ParserGenerator.Input.SourceContext context)
        {
            if (message == null)
                throw new global::System.ArgumentNullException(nameof(message));
            if (context == null)
                throw new global::System.ArgumentNullException(nameof(context));
            return SyntaxError(message, context.Begin);
        }

        public global::ParserGenerator.Exceptions.SyntaxErrorException SyntaxError(string message)
        {
            if (message == null)
                throw new global::System.ArgumentNullException(nameof(message));
            return SyntaxError(message, Reader.Location);
        }

        private static readonly string[] _starts =
        {
            "DEFAULT",
            "STRING_LITERAL"
        };

        private static readonly string[] _tokens =
        {
            "None",
            "IntegerLiteral",
            "FloatLiteral",
            "StringLiteral",
            "'null'",
            "'true'",
            "'false'",
            "'['",
            "','",
            "']'",
            "'{'",
            "'}'",
            "':'"
        };

        private static readonly int[] _start =
        {
            0x00, 0x00, 0x00, 0x01, 0x01, 0x01
        };

        private static readonly int[] _flag =
        {
            0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
            0x0000, 0x0000, 0x0085, 0x0085, 0x00C5, 0x00C5, 0x0075, 0x0075,
            0x0095, 0x0095, 0x00A5, 0x00A5, 0x00B5, 0x00B5, 0x0061, 0x0061,
            0x0071, 0x0071, 0x0000, 0x0000, 0x0000, 0x0000, 0x0081, 0x0081,
            0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0091, 0x0091,
            0x00A1, 0x00A1, 0x00B1, 0x00B1, 0x00B1, 0x00B1, 0x0000, 0x0000,
            0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
            0x0000, 0x0000, 0x00C1, 0x00C1, 0x0000, 0x0000, 0x0000, 0x0000,
            0x00D1, 0x00D1, 0x00E1, 0x00E1, 0x00F1, 0x00F1, 0x0101, 0x0101,
            0x0111, 0x0111, 0x0121, 0x0121, 0x0131, 0x0131, 0x0141, 0x0141,
            0x0151, 0x0151, 0x0161, 0x0161, 0x0171, 0x0171, 0x0181, 0x0181,
            0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
            0x0000, 0x0000, 0x0191, 0x0191, 0x0000, 0x0000, 0x0000, 0x0000,
            0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x00C1, 0x00C1,
            0x01A1, 0x01A1, 0x0181, 0x0181, 0x01B1, 0x01B1, 0x0000, 0x0000,
            0x0000, 0x0000, 0x0000, 0x0000, 0x0045, 0x0045, 0x0055, 0x0055,
            0x01E1, 0x01E1, 0x01F1, 0x01F1, 0x0000, 0x0000, 0x0181, 0x0181,
            0x0000, 0x0000, 0x0000, 0x0000, 0x0065, 0x0065, 0x0000, 0x0000,
            0x0000, 0x0000, 0x0211, 0x0211, 0x0000, 0x0000, 0x0000, 0x0000,
            0x0000, 0x0000, 0x0000, 0x0000, 0x0221, 0x0221
        };

        private static readonly int[] _fast =
        {
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x01, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x04,
            0x00, 0x00, 0x00, 0x05, 0x06, 0x07, 0x08, 0x00,
            0x09, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A,
            0x0B, 0x0B, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x0D,
            0x00, 0x0E, 0x0E, 0x0E, 0x0E, 0x0F, 0x0E, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x11, 0x12, 0x13, 0x00, 0x00,
            0x00, 0x14, 0x15, 0x0E, 0x0E, 0x16, 0x17, 0x00,
            0x00, 0x18, 0x00, 0x00, 0x19, 0x00, 0x1A, 0x00,
            0x00, 0x00, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x00,
            0x20, 0x00, 0x00, 0x21, 0x00, 0x22, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
        };

        private static readonly int[] _first =
        {
            0x0000, 0x0009, 0x000A, 0x000E, 0x0020, 0x0021, 0x0022, 0x0023,
            0x0027, 0x0028, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, 0x0030,
            0x0031, 0x0038, 0x003A, 0x003B, 0x003F, 0x0040, 0x0041, 0x0045,
            0x0046, 0x0047, 0x0055, 0x0056, 0x005B, 0x005C, 0x005D, 0x005E,
            0x0061, 0x0062, 0x0063, 0x0065, 0x0066, 0x0067, 0x0069, 0x006A,
            0x006C, 0x006D, 0x006E, 0x006F, 0x0072, 0x0073, 0x0074, 0x0075,
            0x0076, 0x0077, 0x0078, 0x0079, 0x007B, 0x007C, 0x007D, 0x007E,
            0x0085, 0x0086, 0x00A0, 0x00A1, 0x2000, 0x200B, 0x2028, 0x202A,
            0x202F, 0x2030, 0x205F, 0x2060, 0x3000, 0x3001
        };

        private static readonly int[] _last =
        {
            0x00000008, 0x00000009, 0x0000000D, 0x0000001F,
            0x00000020, 0x00000021, 0x00000022, 0x00000026,
            0x00000027, 0x0000002A, 0x0000002B, 0x0000002C,
            0x0000002D, 0x0000002E, 0x0000002F, 0x00000030,
            0x00000037, 0x00000039, 0x0000003A, 0x0000003E,
            0x0000003F, 0x00000040, 0x00000044, 0x00000045,
            0x00000046, 0x00000054, 0x00000055, 0x0000005A,
            0x0000005B, 0x0000005C, 0x0000005D, 0x00000060,
            0x00000061, 0x00000062, 0x00000064, 0x00000065,
            0x00000066, 0x00000068, 0x00000069, 0x0000006B,
            0x0000006C, 0x0000006D, 0x0000006E, 0x00000071,
            0x00000072, 0x00000073, 0x00000074, 0x00000075,
            0x00000076, 0x00000077, 0x00000078, 0x0000007A,
            0x0000007B, 0x0000007C, 0x0000007D, 0x00000084,
            0x00000085, 0x0000009F, 0x000000A0, 0x00001FFF,
            0x0000200A, 0x00002027, 0x00002029, 0x0000202E,
            0x0000202F, 0x0000205E, 0x0000205F, 0x00002FFF,
            0x00003000, 0x0010FFFF
        };

        private static readonly int[] _map =
        {
            0x00, 0x01, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00,
            0x04, 0x00, 0x05, 0x06, 0x07, 0x08, 0x00, 0x09,
            0x0A, 0x0B, 0x0C, 0x00, 0x0D, 0x00, 0x0E, 0x0F,
            0x0E, 0x00, 0x10, 0x00, 0x11, 0x12, 0x13, 0x00,
            0x14, 0x15, 0x0E, 0x16, 0x17, 0x00, 0x18, 0x00,
            0x19, 0x00, 0x1A, 0x00, 0x1B, 0x1C, 0x1D, 0x1E,
            0x1F, 0x00, 0x20, 0x00, 0x21, 0x00, 0x22, 0x00,
            0x02, 0x00, 0x01, 0x00, 0x01, 0x00, 0x02, 0x00,
            0x01, 0x00, 0x01, 0x00, 0x01, 0x00
        };

        private static readonly int[] _sbase =
        {
            0x0022, 0x0000, 0x0031, 0x0020, 0x0038, 0x0002, 0x0002, 0x0002,
            0x0002, 0x0002, 0x0002, 0x0002, 0x0001, 0x005A, 0x0056, 0x0027,
            0x0062, 0x005E, 0x0086, 0x0002, 0x0002, 0x003D, 0x0002, 0x0040,
            0x0058, 0x003C, 0x0037, 0x0063, 0x000C, 0x0124, 0x0132, 0x005C,
            0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002,
            0x0002, 0x0002, 0x0002, 0x002E, 0x00BB, 0x008E, 0x00E8, 0x0032,
            0x0033, 0x0002, 0x0035, 0x002B, 0x0024, 0x012B, 0x0077, 0x0077,
            0x0002, 0x003F, 0x00BB, 0x00F7, 0x00CA, 0x003A, 0x0002, 0x0002,
            0x0002, 0x0002, 0x0077, 0x0002, 0x00D9, 0x0106, 0x0002, 0x00AC,
            0x009D, 0x0002, 0x007F, 0x0070, 0x0061, 0x0115, 0x0002
        };

        private static readonly int[] _scheck =
        {
            0x00, 0x01, 0x01, 0x03, 0x04, 0x05, 0x06, 0x07,
            0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
            0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
            0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
            0x20, 0x21, 0x22, 0x01, 0x02, 0x03, 0x1A, 0x05,
            0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x08,
            0x09, 0x0A, 0x0B, 0x11, 0x14, 0x13, 0x0F, 0x09,
            0x0A, 0x17, 0x18, 0x17, 0x1A, 0x16, 0x1E, 0x1D,
            0x03, 0x04, 0x17, 0x21, 0x22, 0x14, 0x09, 0x0A,
            0x09, 0x0A, 0x0D, 0x16, 0x19, 0x10, 0x1C, 0x12,
            0x16, 0x14, 0x15, 0x1B, 0x17, 0x1E, 0x1A, 0x1A,
            0x1B, 0x19, 0x1D, 0x1E, 0x1F, 0x20, 0x08, 0x09,
            0x0A, 0x0B, 0x08, 0x09, 0x0A, 0x0B, 0x08, 0x09,
            0x0A, 0x0B, 0x09, 0x0A, 0x0B, 0x0F, 0x18, 0x0E,
            0x0F, 0x19, 0x18, 0x17, 0x16, 0x14, 0x15, 0x16,
            0x17, 0x09, 0x0A, 0x0B, 0x1A, 0x1A, 0x0E, 0x0F,
            0x09, 0x0A, 0x0B, 0x23, 0x14, 0x15, 0x16, 0x17,
            0x09, 0x0A, 0x0B, 0x23, 0x23, 0x0E, 0x0F, 0x09,
            0x0A, 0x0B, 0x23, 0x14, 0x15, 0x16, 0x17, 0x09,
            0x0A, 0x0B, 0x23, 0x23, 0x0E, 0x0F, 0x23, 0x23,
            0x23, 0x23, 0x14, 0x15, 0x16, 0x17, 0x09, 0x0A,
            0x0B, 0x23, 0x23, 0x0E, 0x0F, 0x23, 0x23, 0x23,
            0x23, 0x14, 0x15, 0x16, 0x17, 0x09, 0x0A, 0x0B,
            0x23, 0x23, 0x0E, 0x0F, 0x23, 0x23, 0x23, 0x23,
            0x14, 0x15, 0x16, 0x17, 0x09, 0x0A, 0x0B, 0x23,
            0x23, 0x0E, 0x0F, 0x23, 0x23, 0x23, 0x23, 0x14,
            0x15, 0x16, 0x17, 0x09, 0x0A, 0x0B, 0x23, 0x23,
            0x0E, 0x0F, 0x23, 0x23, 0x23, 0x23, 0x14, 0x15,
            0x16, 0x17, 0x09, 0x0A, 0x0B, 0x23, 0x23, 0x0E,
            0x0F, 0x23, 0x23, 0x23, 0x23, 0x14, 0x15, 0x16,
            0x17, 0x09, 0x0A, 0x0B, 0x23, 0x23, 0x0E, 0x0F,
            0x23, 0x23, 0x23, 0x23, 0x14, 0x15, 0x16, 0x17,
            0x09, 0x0A, 0x0B, 0x23, 0x23, 0x0E, 0x0F, 0x23,
            0x23, 0x23, 0x23, 0x14, 0x15, 0x16, 0x17, 0x09,
            0x0A, 0x0B, 0x23, 0x23, 0x0E, 0x0F, 0x23, 0x23,
            0x23, 0x23, 0x14, 0x15, 0x16, 0x17, 0x09, 0x0A,
            0x0B, 0x23, 0x23, 0x0E, 0x0F, 0x23, 0x23, 0x23,
            0x23, 0x14, 0x15, 0x16, 0x17, 0x09, 0x0A, 0x0B,
            0x05, 0x23, 0x07, 0x0F, 0x09, 0x0A, 0x0B, 0x05,
            0x23, 0x07, 0x16, 0x09, 0x0A, 0x0B, 0x23, 0x23,
            0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23,
            0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23,
            0x23, 0x23, 0x23, 0x23, 0x23
        };

        private static readonly int[] _svalue =
        {
            0x16, 0x16, 0x0C, 0x14, 0x16, 0x16, 0x16, 0x16,
            0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16,
            0x16, 0x16, 0x15, 0x16, 0x16, 0x16, 0x16, 0x16,
            0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16,
            0x16, 0x16, 0x16, 0x0C, 0x0B, 0x13, 0x34, 0x0D,
            0x05, 0x0E, 0x12, 0x11, 0x0F, 0x0F, 0x06, 0x1D,
            0x0F, 0x0F, 0x0F, 0x07, 0x19, 0x08, 0x1E, 0x39,
            0x39, 0x02, 0x10, 0x41, 0x03, 0x1E, 0x18, 0x04,
            0x21, 0x20, 0x40, 0x09, 0x0A, 0x17, 0x2B, 0x2B,
            0x43, 0x43, 0x22, 0x3F, 0x3E, 0x2E, 0x3D, 0x23,
            0x46, 0x24, 0x25, 0x1A, 0x29, 0x32, 0x31, 0x27,
            0x2A, 0x2F, 0x26, 0x2D, 0x28, 0x2C, 0x12, 0x11,
            0x0F, 0x0F, 0x12, 0x11, 0x0F, 0x0F, 0x1D, 0x11,
            0x11, 0x11, 0x4D, 0x4D, 0x4D, 0x1E, 0x1C, 0x4D,
            0x4D, 0x30, 0x1B, 0x38, 0x1E, 0x4D, 0x4D, 0x4D,
            0x4D, 0x4C, 0x4C, 0x4C, 0x1F, 0x33, 0x4C, 0x4C,
            0x37, 0x37, 0x37, 0x00, 0x4C, 0x4C, 0x4C, 0x4C,
            0x4B, 0x4B, 0x4B, 0x00, 0x00, 0x4B, 0x4B, 0x1D,
            0x1D, 0x1D, 0x00, 0x4B, 0x4B, 0x4B, 0x4B, 0x3B,
            0x3B, 0x3B, 0x00, 0x00, 0x3B, 0x3B, 0x00, 0x00,
            0x00, 0x00, 0x3B, 0x3B, 0x3B, 0x3B, 0x4A, 0x4A,
            0x4A, 0x00, 0x00, 0x4A, 0x4A, 0x00, 0x00, 0x00,
            0x00, 0x4A, 0x4A, 0x4A, 0x4A, 0x49, 0x49, 0x49,
            0x00, 0x00, 0x49, 0x49, 0x00, 0x00, 0x00, 0x00,
            0x49, 0x49, 0x49, 0x49, 0x3A, 0x3A, 0x3A, 0x00,
            0x00, 0x3A, 0x3A, 0x00, 0x00, 0x00, 0x00, 0x3A,
            0x3A, 0x3A, 0x3A, 0x45, 0x45, 0x45, 0x00, 0x00,
            0x45, 0x45, 0x00, 0x00, 0x00, 0x00, 0x45, 0x45,
            0x45, 0x45, 0x47, 0x47, 0x47, 0x00, 0x00, 0x47,
            0x47, 0x00, 0x00, 0x00, 0x00, 0x47, 0x47, 0x47,
            0x47, 0x3C, 0x3C, 0x3C, 0x00, 0x00, 0x3C, 0x3C,
            0x00, 0x00, 0x00, 0x00, 0x3C, 0x3C, 0x3C, 0x3C,
            0x44, 0x44, 0x44, 0x00, 0x00, 0x44, 0x44, 0x00,
            0x00, 0x00, 0x00, 0x44, 0x44, 0x44, 0x44, 0x48,
            0x48, 0x48, 0x00, 0x00, 0x48, 0x48, 0x00, 0x00,
            0x00, 0x00, 0x48, 0x48, 0x48, 0x48, 0x4E, 0x4E,
            0x4E, 0x00, 0x00, 0x4E, 0x4E, 0x00, 0x00, 0x00,
            0x00, 0x4E, 0x4E, 0x4E, 0x4E, 0x1D, 0x1D, 0x1D,
            0x42, 0x00, 0x42, 0x35, 0x37, 0x37, 0x37, 0x36,
            0x00, 0x36, 0x35, 0x37, 0x37, 0x37
        };

        private static readonly string[] _goals =
        {
            "JsonValue"
        };

        private static readonly string[] _nonterminals =
        {
            "JsonValue",
            "KeyValuePair",
            "JsonValue'",
            "JsonValueList",
            "OptionalJsonValueList",
            "KeyValuePairList",
            "OptionalKeyValuePairList"
        };

        private static readonly string[] _text =
        {
            "end marker",
            "integer literal",
            "float literal",
            "string literal",
            "'null'",
            "'true'",
            "'false'",
            "'['",
            "','",
            "']'",
            "'{'",
            "'}'",
            "':'"
        };

        private static readonly int[] _goal =
        {
            0x00
        };

        private static readonly int[] _left =
        {
            0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x03, 0x03, 0x04, 0x04, 0x00, 0x05, 0x05, 0x06,
            0x06, 0x01
        };

        private static readonly int[] _length =
        {
            0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03,
            0x01, 0x03, 0x00, 0x01, 0x03, 0x01, 0x03, 0x00,
            0x01, 0x03
        };

        private static readonly int[] _pbase =
        {
            0x3C, 0x02, 0x05, 0x0B, 0x0F, 0x19, 0x1D, 0x23,
            0x32, 0x26, 0x40, 0x45, 0x43, 0x39, 0x3F, 0x3D,
            0x46, 0x01, 0x3C, 0x27, 0x03, 0x3C, 0x17, 0x22,
            0x13, 0x00, 0x08, 0x04, 0x47, 0x48, 0x31, 0x4A
        };

        private static readonly int[] _pcheck =
        {
            0x00, 0x00, 0x00, 0x19, 0x19, 0x00, 0x03, 0x19,
            0x08, 0x08, 0x09, 0x00, 0x0B, 0x08, 0x09, 0x00,
            0x0B, 0x09, 0x12, 0x08, 0x09, 0x15, 0x0B, 0x08,
            0x09, 0x00, 0x0B, 0x08, 0x14, 0x00, 0x0B, 0x08,
            0x09, 0x08, 0x09, 0x00, 0x0B, 0x08, 0x09, 0x00,
            0x0B, 0x03, 0x08, 0x08, 0x09, 0x0B, 0x0B, 0x08,
            0x09, 0x0B, 0x0B, 0x01, 0x02, 0x03, 0x04, 0x05,
            0x06, 0x07, 0x09, 0x09, 0x0A, 0x01, 0x02, 0x03,
            0x04, 0x05, 0x06, 0x07, 0x0B, 0x08, 0x0A, 0x08,
            0x0B, 0x09, 0x0B, 0x08, 0x09, 0x08, 0x09, 0x08,
            0x08, 0x19, 0x0C, 0x09, 0x19, 0x19, 0x19, 0x19,
            0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19,
            0x19, 0x19, 0x19
        };

        private static readonly int[] _pvalue =
        {
            0x0001, 0x0072, 0x0006, 0x0000, 0x0000, 0x0012, 0x0101, 0x0000,
            0x000C, 0x0072, 0x0072, 0x0022, 0x0072, 0x0012, 0x0012, 0x0032,
            0x0012, 0x000F, 0x0016, 0x0022, 0x0022, 0x0018, 0x0022, 0x0032,
            0x0032, 0x0042, 0x0032, 0x0112, 0x0017, 0x0052, 0x0112, 0x0092,
            0x0092, 0x0042, 0x0042, 0x0062, 0x0042, 0x0052, 0x0052, 0x00C2,
            0x0052, 0x0101, 0x00E2, 0x0062, 0x0062, 0x00E2, 0x0062, 0x00C2,
            0x00C2, 0x00F2, 0x00C2, 0x0051, 0x0061, 0x0071, 0x0021, 0x0031,
            0x0041, 0x0081, 0x000E, 0x00A2, 0x0091, 0x0051, 0x0061, 0x0071,
            0x0021, 0x0031, 0x0041, 0x0081, 0x0131, 0x00D2, 0x0091, 0x0141,
            0x00D2, 0x0111, 0x0102, 0x0082, 0x0082, 0x0121, 0x00B2, 0x000B,
            0x000A, 0x0000, 0x0151, 0x000D
        };

        private static int Map(int c)
        {
            if (0 <= c && c <= _fast.Length)
                return _fast[c];
            int i = 0;
            int j = _map.Length - 1;
            while (i <= j)
            {
                int k = i + (j - i >> 1);
                if (c < _first[k])
                    j = k - 1;
                else if (_last[k] < c)
                    i = k + 1;
                else
                    return _map[k];
            }
            return -1;
        }

        private static int Move(int state, int c)
        {
            int k = Map(c);
            if (k == -1)
                return -1;
            if (_scheck[_sbase[state] + k] == k)
                return _svalue[_sbase[state] + k];
            else
                return -1;
        }

        private static bool IsLineTerminator(int c)
        {
            switch (c)
            {
                case 0x000a: // '\n'
                case 0x000b: // '\v'
                case 0x000c: // '\f'
                case 0x000d: // '\r'
                case 0x0085: // '\u0085'
                case 0x2028: // '\u2028'
                case 0x2029: // '\u2029'
                    return true;
                default:
                    return false;
            }
        }

        private int ScanNextToken()
        {
            while (true)
            {
                TokenBegin = TokenEnd = Reader.Location;
                if (_start[_currentStart * 3 + 2] == 0 && Reader.Peek() == -1)
                    return 0;
                int saved = -1;
                int start = _currentStart;
                int state = _start[start * 3 + (Reader.Location.Offset == 0 ? 0 : 1)];
                while (true)
                {
                    int c = Reader.Read();
                    if (c == -1)
                        break;
                    int result = Move(state, c);
                    if (result == -1)
                        break;
                    int flag = _flag[result * 2];
                    if ((flag & 0x1) != 0)
                    {
                        int flag2 = _flag[result * 2 + 1];
                        bool atEOL = IsLineTerminator(Reader.Peek()) || Reader.Peek() == -1;
                        if ((flag & 0x2) == 0 || atEOL || (flag2 & 0x1) != 0)
                        {
                            TokenEnd = Reader.Location;
                            saved = result;
                        }
                    }
                    state = result;
                }
                if (saved == -1)
                {
                    Reader.Location = TokenBegin;
                    TokenContext = global::ParserGenerator.Input.SourceContext.New(TokenBegin, Reader.Location);
                    switch (start)
                    {
                        case 1:
                            // #line 96 "C:\Users\huaidong.xiong\Documents\git\ParserGenerator\ParserGenerator\ParserGenerator.Languages\JSON\JSON.g"

                                throw UnterminatedStringLiteral();
                            // #line default
                        default:
                            throw SyntaxError(global::ParserGenerator.SR.InvalidToken);
                    }
                }
                else
                {
                    Reader.Location = TokenEnd;
                    TokenContext = global::ParserGenerator.Input.SourceContext.New(TokenBegin, Reader.Location);
                    int flag = _flag[saved * 2];
                    int flag2 = _flag[saved * 2 + 1];
                    bool atEOL = IsLineTerminator(Reader.Peek()) || Reader.Peek() == -1;
                    int action = (flag & 0x2) == 0 || atEOL ? flag : flag2;
                    if ((action & 0x4) != 0)
                        return action >> 4;
                    int rule = action >> 4;
                    switch (rule)
                    {
                        case 6:
                            // nl
                            // #line 52 "C:\Users\huaidong.xiong\Documents\git\ParserGenerator\ParserGenerator\ParserGenerator.Languages\JSON\JSON.g"

                                ;
                            // #line default
                            break;
                        case 7:
                            // ws
                            // #line 53 "C:\Users\huaidong.xiong\Documents\git\ParserGenerator\ParserGenerator\ParserGenerator.Languages\JSON\JSON.g"

                                ;
                            // #line default
                            break;
                        case 8:
                            // decimal_constant
                            // #line 58 "C:\Users\huaidong.xiong\Documents\git\ParserGenerator\ParserGenerator\ParserGenerator.Languages\JSON\JSON.g"

                                ScanIntegerLiteral();
                                return 1;
                            // #line default
                        case 9:
                            // '"'
                            // #line 76 "C:\Users\huaidong.xiong\Documents\git\ParserGenerator\ParserGenerator\ParserGenerator.Languages\JSON\JSON.g"

                                BeginString(1);
                            // #line default
                            break;
                        case 10:
                            // '"'
                            // #line 79 "C:\Users\huaidong.xiong\Documents\git\ParserGenerator\ParserGenerator\ParserGenerator.Languages\JSON\JSON.g"

                                EndString();
                                return 3;
                            // #line default
                        case 11:
                            // nnl
                            // #line 95 "C:\Users\huaidong.xiong\Documents\git\ParserGenerator\ParserGenerator\ParserGenerator.Languages\JSON\JSON.g"

                                AppendTokenString();
                            // #line default
                            break;
                        case 12:
                            // decimal_floating_constant
                            // #line 70 "C:\Users\huaidong.xiong\Documents\git\ParserGenerator\ParserGenerator\ParserGenerator.Languages\JSON\JSON.g"

                                ScanFloatLiteral();
                                return 2;
                            // #line default
                        case 13:
                            // "\\'"
                            // #line 80 "C:\Users\huaidong.xiong\Documents\git\ParserGenerator\ParserGenerator\ParserGenerator.Languages\JSON\JSON.g"

                                AppendChar('\'');
                            // #line default
                            break;
                        case 14:
                            // "\\\""
                            // #line 81 "C:\Users\huaidong.xiong\Documents\git\ParserGenerator\ParserGenerator\ParserGenerator.Languages\JSON\JSON.g"

                                AppendChar('"');
                            // #line default
                            break;
                        case 15:
                            // "\\?"
                            // #line 82 "C:\Users\huaidong.xiong\Documents\git\ParserGenerator\ParserGenerator\ParserGenerator.Languages\JSON\JSON.g"

                                AppendChar('?');
                            // #line default
                            break;
                        case 16:
                            // "\\\\"
                            // #line 83 "C:\Users\huaidong.xiong\Documents\git\ParserGenerator\ParserGenerator\ParserGenerator.Languages\JSON\JSON.g"

                                AppendChar('\\');
                            // #line default
                            break;
                        case 17:
                            // "\\a"
                            // #line 84 "C:\Users\huaidong.xiong\Documents\git\ParserGenerator\ParserGenerator\ParserGenerator.Languages\JSON\JSON.g"

                                AppendChar('\a');
                            // #line default
                            break;
                        case 18:
                            // "\\b"
                            // #line 85 "C:\Users\huaidong.xiong\Documents\git\ParserGenerator\ParserGenerator\ParserGenerator.Languages\JSON\JSON.g"

                                AppendChar('\b');
                            // #line default
                            break;
                        case 19:
                            // "\\t"
                            // #line 86 "C:\Users\huaidong.xiong\Documents\git\ParserGenerator\ParserGenerator\ParserGenerator.Languages\JSON\JSON.g"

                                AppendChar('\t');
                            // #line default
                            break;
                        case 20:
                            // "\\n"
                            // #line 87 "C:\Users\huaidong.xiong\Documents\git\ParserGenerator\ParserGenerator\ParserGenerator.Languages\JSON\JSON.g"

                                AppendChar('\n');
                            // #line default
                            break;
                        case 21:
                            // "\\v"
                            // #line 88 "C:\Users\huaidong.xiong\Documents\git\ParserGenerator\ParserGenerator\ParserGenerator.Languages\JSON\JSON.g"

                                AppendChar('\v');
                            // #line default
                            break;
                        case 22:
                            // "\\f"
                            // #line 89 "C:\Users\huaidong.xiong\Documents\git\ParserGenerator\ParserGenerator\ParserGenerator.Languages\JSON\JSON.g"

                                AppendChar('\f');
                            // #line default
                            break;
                        case 23:
                            // "\\r"
                            // #line 90 "C:\Users\huaidong.xiong\Documents\git\ParserGenerator\ParserGenerator\ParserGenerator.Languages\JSON\JSON.g"

                                AppendChar('\r');
                            // #line default
                            break;
                        case 24:
                            // "\\" ['0'-'7']{1,3}
                            // #line 91 "C:\Users\huaidong.xiong\Documents\git\ParserGenerator\ParserGenerator\ParserGenerator.Languages\JSON\JSON.g"

                                AppendEscape(-1, true);
                            // #line default
                            break;
                        case 25:
                            // 'nan'
                            // #line 66 "C:\Users\huaidong.xiong\Documents\git\ParserGenerator\ParserGenerator\ParserGenerator.Languages\JSON\JSON.g"

                                TokenValue = double.NaN;
                                return 2;
                            // #line default
                        case 26:
                            // 'inf'
                            // #line 67 "C:\Users\huaidong.xiong\Documents\git\ParserGenerator\ParserGenerator\ParserGenerator.Languages\JSON\JSON.g"

                                TokenValue = double.PositiveInfinity;
                                return 2;
                            // #line default
                        case 27:
                            // "\\x" hex+
                            // #line 92 "C:\Users\huaidong.xiong\Documents\git\ParserGenerator\ParserGenerator\ParserGenerator.Languages\JSON\JSON.g"

                                AppendEscape(-1, false);
                            // #line default
                            break;
                        case 30:
                            // '+inf'
                            // #line 68 "C:\Users\huaidong.xiong\Documents\git\ParserGenerator\ParserGenerator\ParserGenerator.Languages\JSON\JSON.g"

                                TokenValue = double.PositiveInfinity;
                                return 2;
                            // #line default
                        case 31:
                            // '-inf'
                            // #line 69 "C:\Users\huaidong.xiong\Documents\git\ParserGenerator\ParserGenerator\ParserGenerator.Languages\JSON\JSON.g"

                                TokenValue = double.NegativeInfinity;
                                return 2;
                            // #line default
                        case 33:
                            // "\\u" hex_quad
                            // #line 93 "C:\Users\huaidong.xiong\Documents\git\ParserGenerator\ParserGenerator\ParserGenerator.Languages\JSON\JSON.g"

                                AppendEscape(4, false);
                            // #line default
                            break;
                        case 34:
                            // "\\U" hex_quad hex_quad
                            // #line 94 "C:\Users\huaidong.xiong\Documents\git\ParserGenerator\ParserGenerator\ParserGenerator.Languages\JSON\JSON.g"

                                AppendEscape(8, false);
                            // #line default
                            break;
                        default:
                            break;
                    }
                }
            }
        }

        public int GetNextToken()
        {
            TokenContext = null;
            TokenValue = null;
            int tag = ScanNextToken();
            if (TokenContext == null)
                TokenContext = global::ParserGenerator.Input.SourceContext.New(TokenBegin, Reader.Location);
            return tag;
        }

        private static int Action(int state, int c)
        {
            if (_pcheck[_pbase[state] + c] == c)
                return _pvalue[_pbase[state] + c];
            else
                return 0;
        }

        private static int Goto(int state, int c)
        {
            return _pvalue[_pbase[25 + c] + state];
        }

        private global::ParserGenerator.Exceptions.SyntaxErrorException MakeError(int state, int t)
        {
            global::System.Collections.Generic.List<string> tokens = new global::System.Collections.Generic.List<string>();
            for (int c = 0; c < _text.Length; c++)
            {
                int s = Action(state, c);
                if ((s & 0x1) != 0)
                    tokens.Add(_text[c]);
                else if ((s & 0x2) != 0)
                {
                    tokens.Clear();
                    break;
                }
            }
            string message;
            if (tokens.Count == 0)
                message = string.Format(global::ParserGenerator.SR.UnexpectedToken, _text[t]);
            else
            {
                global::System.Text.StringBuilder sb = new global::System.Text.StringBuilder();
                switch (tokens.Count)
                {
                    case 1:
                        sb.Append(tokens[0]);
                        break;
                    case 2:
                        sb.Append(tokens[0]);
                        sb.Append(" or ");
                        sb.Append(tokens[1]);
                        break;
                    case 3:
                        sb.Append(tokens[0]);
                        sb.Append(", ");
                        sb.Append(tokens[1]);
                        sb.Append(", or ");
                        sb.Append(tokens[2]);
                        break;
                    default:
                        sb.Append(tokens[0]);
                        sb.Append(", ");
                        sb.Append(tokens[1]);
                        sb.Append(", ..., or ");
                        sb.Append(tokens[tokens.Count - 1]);
                        break;
                }
                message = string.Format(global::ParserGenerator.SR.ExpectFound, sb.ToString(), _text[t]);
            }
            global::ParserGenerator.Exceptions.SyntaxErrorException e = new global::ParserGenerator.Exceptions.SyntaxErrorException(message);
            e.AddLocation(TokenContext);
            return e;
        }

        private object Reduce(int prod)
        {
            switch (prod)
            {
                case 0:
                    // JsonValue' -> JsonValue
                    return null;
                case 1:
                    // JsonValue -> 'null'
                    {
                        JsonValue result = default(JsonValue);
                        // #line 33 "C:\Users\huaidong.xiong\Documents\git\ParserGenerator\ParserGenerator\ParserGenerator.Languages\JSON\JSON.g"
                        result = JsonValue.NewNull(_nodeContext);
                        // #line default
                        return result;
                    }
                case 2:
                    // JsonValue -> 'true'
                    {
                        JsonValue result = default(JsonValue);
                        // #line 34 "C:\Users\huaidong.xiong\Documents\git\ParserGenerator\ParserGenerator\ParserGenerator.Languages\JSON\JSON.g"
                        result = JsonValue.NewBoolean(true, _nodeContext);
                        // #line default
                        return result;
                    }
                case 3:
                    // JsonValue -> 'false'
                    {
                        JsonValue result = default(JsonValue);
                        // #line 35 "C:\Users\huaidong.xiong\Documents\git\ParserGenerator\ParserGenerator\ParserGenerator.Languages\JSON\JSON.g"
                        result = JsonValue.NewBoolean(false, _nodeContext);
                        // #line default
                        return result;
                    }
                case 4:
                    // JsonValue -> IntegerLiteral
                    {
                        JsonValue result = default(JsonValue);
                        // #line 36 "C:\Users\huaidong.xiong\Documents\git\ParserGenerator\ParserGenerator\ParserGenerator.Languages\JSON\JSON.g"
                        result = JsonValue.NewInteger(((System.Numerics.BigInteger)(_values[_values.Count - 1])), _nodeContext);
                        // #line default
                        return result;
                    }
                case 5:
                    // JsonValue -> FloatLiteral
                    {
                        JsonValue result = default(JsonValue);
                        // #line 37 "C:\Users\huaidong.xiong\Documents\git\ParserGenerator\ParserGenerator\ParserGenerator.Languages\JSON\JSON.g"
                        result = JsonValue.NewFloat(((double)(_values[_values.Count - 1])), _nodeContext);
                        // #line default
                        return result;
                    }
                case 6:
                    // JsonValue -> StringLiteral
                    {
                        JsonValue result = default(JsonValue);
                        // #line 38 "C:\Users\huaidong.xiong\Documents\git\ParserGenerator\ParserGenerator\ParserGenerator.Languages\JSON\JSON.g"
                        result = JsonValue.NewString(((string)(_values[_values.Count - 1])), _nodeContext);
                        // #line default
                        return result;
                    }
                case 7:
                    // JsonValue -> '[' JsonValue % ',' ']'
                    {
                        JsonValue result = default(JsonValue);
                        // #line 39 "C:\Users\huaidong.xiong\Documents\git\ParserGenerator\ParserGenerator\ParserGenerator.Languages\JSON\JSON.g"
                        result = JsonValue.NewArray(((global::ParserGenerator.Collections.Sequence<JsonValue>)(_values[_values.Count - 2])), _nodeContext);
                        // #line default
                        return result;
                    }
                case 8:
                    // JsonValueList -> JsonValue
                    {
                        global::ParserGenerator.Collections.Sequence<JsonValue> result = default(global::ParserGenerator.Collections.Sequence<JsonValue>);
                        result = Sequence.Create(((JsonValue)(_values[_values.Count - 1])));
                        return result;
                    }
                case 9:
                    // JsonValueList -> JsonValueList ',' JsonValue
                    {
                        global::ParserGenerator.Collections.Sequence<JsonValue> result = default(global::ParserGenerator.Collections.Sequence<JsonValue>);
                        result = Sequence.Append(((global::ParserGenerator.Collections.Sequence<JsonValue>)(_values[_values.Count - 3])), ((JsonValue)(_values[_values.Count - 1])));
                        return result;
                    }
                case 10:
                    // OptionalJsonValueList ->
                    {
                        global::ParserGenerator.Collections.Sequence<JsonValue> result = default(global::ParserGenerator.Collections.Sequence<JsonValue>);
                        result = global::ParserGenerator.Collections.Sequence.GetEmpty<JsonValue>();
                        return result;
                    }
                case 11:
                    // OptionalJsonValueList -> JsonValue %+ ','
                    {
                        global::ParserGenerator.Collections.Sequence<JsonValue> result = default(global::ParserGenerator.Collections.Sequence<JsonValue>);
                        result = ((global::ParserGenerator.Collections.Sequence<JsonValue>)(_values[_values.Count - 1]));
                        return result;
                    }
                case 12:
                    // JsonValue -> '{' KeyValuePair % ',' '}'
                    {
                        JsonValue result = default(JsonValue);
                        // #line 40 "C:\Users\huaidong.xiong\Documents\git\ParserGenerator\ParserGenerator\ParserGenerator.Languages\JSON\JSON.g"
                        result = JsonValue.NewObject(((global::ParserGenerator.Collections.Sequence<global::System.Tuple<string, JsonValue>>)(_values[_values.Count - 2])), _nodeContext);
                        // #line default
                        return result;
                    }
                case 13:
                    // KeyValuePairList -> KeyValuePair
                    {
                        global::ParserGenerator.Collections.Sequence<global::System.Tuple<string, JsonValue>> result = default(global::ParserGenerator.Collections.Sequence<global::System.Tuple<string, JsonValue>>);
                        result = Sequence.Create(((global::System.Tuple<string, JsonValue>)(_values[_values.Count - 1])));
                        return result;
                    }
                case 14:
                    // KeyValuePairList -> KeyValuePairList ',' KeyValuePair
                    {
                        global::ParserGenerator.Collections.Sequence<global::System.Tuple<string, JsonValue>> result = default(global::ParserGenerator.Collections.Sequence<global::System.Tuple<string, JsonValue>>);
                        result = Sequence.Append(((global::ParserGenerator.Collections.Sequence<global::System.Tuple<string, JsonValue>>)(_values[_values.Count - 3])), ((global::System.Tuple<string, JsonValue>)(_values[_values.Count - 1])));
                        return result;
                    }
                case 15:
                    // OptionalKeyValuePairList ->
                    {
                        global::ParserGenerator.Collections.Sequence<global::System.Tuple<string, JsonValue>> result = default(global::ParserGenerator.Collections.Sequence<global::System.Tuple<string, JsonValue>>);
                        result = global::ParserGenerator.Collections.Sequence.GetEmpty<global::System.Tuple<string, JsonValue>>();
                        return result;
                    }
                case 16:
                    // OptionalKeyValuePairList -> KeyValuePair %+ ','
                    {
                        global::ParserGenerator.Collections.Sequence<global::System.Tuple<string, JsonValue>> result = default(global::ParserGenerator.Collections.Sequence<global::System.Tuple<string, JsonValue>>);
                        result = ((global::ParserGenerator.Collections.Sequence<global::System.Tuple<string, JsonValue>>)(_values[_values.Count - 1]));
                        return result;
                    }
                case 17:
                    // KeyValuePair -> StringLiteral ':' JsonValue
                    {
                        global::System.Tuple<string, JsonValue> result = default(global::System.Tuple<string, JsonValue>);
                        // #line 43 "C:\Users\huaidong.xiong\Documents\git\ParserGenerator\ParserGenerator\ParserGenerator.Languages\JSON\JSON.g"
                        result = global::System.Tuple.Create(((string)(_values[_values.Count - 3])), ((JsonValue)(_values[_values.Count - 1])));
                        // #line default
                        return result;
                    }
                default:
                    return null;
            }
        }

        private object ParseGoal(int goal)
        {
            int state = _goal[goal];
            _states.Add(state);
            int t = GetNextToken();
            while (true)
            {
                int s = Action(state, t);
                if ((s & 0x1) != 0)
                {
                    state = s >> 4;
                    _states.Add(state);
                    _symbols.Add(_tokens[t]);
                    _values.Add(TokenValue);
                    _contexts.Add(TokenContext);
                    t = GetNextToken();
                }
                else if ((s & 0x2) != 0)
                {
                    int prod = s >> 4;
                    int left = _left[prod];
                    int length = _length[prod];
                    if (length == 0)
                        _nodeContext = global::ParserGenerator.Input.SourceContext.New(TokenContext.Begin, TokenContext.Begin);
                    else
                        _nodeContext = global::ParserGenerator.Input.SourceContext.New(_contexts[_contexts.Count - length].Begin, _contexts[_contexts.Count - 1].End);
                    if ((s & 0x4) != 0)
                    {
                        object result = _values[0];
                        _states.Clear();
                        _symbols.Clear();
                        _values.Clear();
                        _contexts.Clear();
                        return result;
                    }
                    else
                    {
                        object value = Reduce(prod);
                        if (length > 0)
                        {
                            _states.RemoveRange(_states.Count - length, length);
                            _symbols.RemoveRange(_symbols.Count - length, length);
                            _values.RemoveRange(_values.Count - length, length);
                            _contexts.RemoveRange(_contexts.Count - length, length);
                        }
                        state = Goto(_states[_states.Count - 1], left);
                        _states.Add(state);
                        _symbols.Add(_nonterminals[left]);
                        _values.Add(value);
                        _contexts.Add(_nodeContext);
                    }
                }
                else
                {
                    throw MakeError(state, t);
                }
            }
        }

        public JsonValue Parse()
        {
            return ParseJsonValue();
        }

        public JsonValue ParseJsonValue()
        {
            return (JsonValue)ParseGoal(0);
        }

        public static void TestTokenizer()
        {
            while (true)
            {
                global::ParserGenerator.Input.SourceReader reader = global::ParserGenerator.Input.SourceReader.FromConsole();
                if (reader.Peek() == -1)
                    break;
                try
                {
                    global::ParserGenerator.Languages.JSON.JSONParser tokenizer = new global::ParserGenerator.Languages.JSON.JSONParser(reader);
                    while (true)
                    {
                        int tag = tokenizer.GetNextToken();
                        global::System.Console.WriteLine("{0}: {1} {2}", tokenizer.TokenContext.Begin, _tokens[tag], tokenizer.TokenContext);
                        if (tag == 0)
                            break;
                    }
                }
                catch (global::System.Exception e)
                {
                    global::ParserGenerator.Extensions.ExceptionExtensions.Print(e);
                }
            }
        }

        public static void Test()
        {
            while (true)
            {
                global::ParserGenerator.Input.SourceReader reader = global::ParserGenerator.Input.SourceReader.FromConsole();
                if (reader.Peek() == -1)
                    break;
                try
                {
                    global::ParserGenerator.Languages.JSON.JSONParser parser = new global::ParserGenerator.Languages.JSON.JSONParser(reader);
                    JsonValue ast = parser.Parse();
                    string str = ast.ToString();
                    if (!string.IsNullOrWhiteSpace(str))
                        global::System.Console.WriteLine(str);
                }
                catch (global::System.Exception e)
                {
                    global::ParserGenerator.Extensions.ExceptionExtensions.Print(e);
                }
            }
        }
    }
}
